SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TB_UserCard]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[TB_UserCard](
	[n4UserCardNo] [int] IDENTITY(1,1) NOT NULL,
	[n4UserNo] [int] NOT NULL,
	[strCardNo] [varchar](100) NOT NULL,
	[CodeStatus] [tinyint] NOT NULL,
	[dtCreateDate] [datetime] NOT NULL,
	[dtModifyDate] [datetime] NOT NULL,
	[dtRemoveDate] [datetime] NULL,
	[strModifyManagerName] [nvarchar](50) NULL,
	[strDesc] [nvarchar](1000) NULL,
 CONSTRAINT [PK_TB_UserCard] PRIMARY KEY CLUSTERED 
(
	[n4UserCardNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_UserCard]') AND name = N'IX_TB_UserCard_CodeStatus_n4UserCardNo')
CREATE NONCLUSTERED INDEX [IX_TB_UserCard_CodeStatus_n4UserCardNo] ON [dbo].[TB_UserCard] 
(
	[CodeStatus] ASC,
	[n4UserCardNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_UserCard]') AND name = N'IX_TB_UserCard_n4UserNo_n4UserCardNo')
CREATE NONCLUSTERED INDEX [IX_TB_UserCard_n4UserNo_n4UserCardNo] ON [dbo].[TB_UserCard] 
(
	[n4UserNo] ASC,
	[n4UserCardNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TB_UserCard]') AND name = N'UIX_TB_UserCard_strCardNo')
CREATE UNIQUE NONCLUSTERED INDEX [UIX_TB_UserCard_strCardNo] ON [dbo].[TB_UserCard] 
(
	[strCardNo] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
